<?php

class UnionScript extends ScriptBase
{
	private $mysql = null;

	public function __construct()
	{
		$this->mysql = n_api('mysql')->cname('weixin');
	}

	public function fuck()
	{
		$rs = n_api('weixin')->get_groups();
		foreach ($rs as $value) {
			$groups[$value['name']] = $value['id'];
		}
		$query = "select * from weixin_main where isdel ='N'";
		$rs = $this->mysql->select($query);
		foreach ($rs as $value) {
			$category = $value['category'];
			$groupId = $groups[$category];
			$update = ['group_id' => $groupId];
			$where = "id = {$value['id']}";
			$this->mysql->update('weixin_main', $update, $where);
		}
	}
}